package com.demo.service.impl;

import com.demo.dao.UserDao;
import com.demo.entity.User;
import com.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;


    @Override
    public User findById(Integer id) {
        return userDao.queryById(id);
    }

    @Override
    public User saveOne(User user) {
        return userDao.save(user);
    }

    @Override
    public void deleteAll() {
        userDao.deleteAll();
        userDao.updateAutoIncrement(1);
    }
}
